package com.example.sudoku;

import java.util.Scanner;
public class SuDoKuMain {
    public static void Sudokumain(int rank) {
    	CreateBoard newBoard = new CreateBoard();
        int i;
        Scanner input=new Scanner(System.in);
//        System.out.println("please input the size:(9/16)");
//        i=input.nextInt();
        // 9/16 目前默认为9
        i = 9;
        while(i!=9&&i!=16)
        {
            System.out.println("please input the size:(9/16)");
            i=input.nextInt();
        }
        if(i==9) SaveBoard.change_size9();
        else SaveBoard.change_size16();
        System.out.println("please input the level:(0:easy 1:medium 2:hard 3:very hard)");
//        i=input.nextInt();
        // 根据rank选择难度
        i = rank;
        while(i<0||i>3)
        {
            System.out.println("please input the level:(0:easy 1:medium 2:hard 3:very hard)");
            i=input.nextInt();
        }
        if(SaveBoard.return_size()==9){
            System.out.println("please input the number(1~9)");
            if(i==0) i=10;//easy
            else if(i==1) i=30;//medium
            else if(i==2) i=40;//hard
            else i=50;//very hard
        }
        else{
            System.out.println("please input the number(1~9,A~G)");
            if(i==0) i=20;//easy
            else if(i==1) i=50;//medium
            else if(i==2) i=80;//hard
            else i=100;//very hard
        }
        System.out.println("wait please");
        newBoard.run(i);//生成数独
        newBoard.printBoard();//打印数独
        SudokuDLX sudokuDLX = new SudokuDLX();
    
        sudokuDLX.solve(newBoard.board);//生成数独的解
          
        System.out.println("Do you want to know the answer?(Y:0)");
//        i=input.nextInt();
        // 0输出答案，默认为1
        i = 1;
        if(i==0)
        	CreateBoard.printBoard(sudokuDLX.solutionBoard);//打印数独的解
//        System.out.println("Good job!");
    }
}
